package conf

import (
	"fmt"
	"github.com/spf13/viper"
)

type Config struct {
	MySqlConfig
}

type MySqlConfig struct {
	User     string
	Password string
	Host     string
	Port     int
	Database string
}

var AppConf Config

func Init() {
	viper.SetConfigFile("./conf/conf.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("配置文件读取失败")
		return
	}

	err = viper.Unmarshal(&AppConf)
	if err != nil {
		fmt.Println("配置解析失败")
		return
	}
	fmt.Println("配置文件读取成功")
}
